<style type="text/css">
    .pic-lodd{width: 145px;position: fixed;top: 40%;margin-top:-8px;left: 50%;margin-left: -73px; z-index: 99;border: 1px solid #ccc;border-radius: 5px;display: none;}
</style>
<div class="pic-lodd"><img width="100%" src="__PUBLIC__/images/lodding-ckl.gif"/></div>
<script type="text/javascript">
var xhr;
function createXMLHttpRequest(){
    if(window.ActiveXObject)    {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }else if(window.XMLHttpRequest){
        xhr = new XMLHttpRequest();
    }
}
//上传图片
function UpladFile(obj,url,res){
    var fileObj = document.getElementById(obj).files[0];
    var FileController = url;
    var form = new FormData();
    form.append("myfile", fileObj);
    createXMLHttpRequest();
    xhr.onreadystatechange = $('.pic-lodd').show();
    xhr.open("post", FileController, true);
    xhr.send(form);

    if(xhr.readyState > 0 )
    {
        if (xhr.status == 200 || xhr.status == 0)
        {
            alert('上传成功');
            $('.pic-lodd').hide();
            var result = xhr.responseText;
            var json = eval("(" + result + ")");
            $('#'+res).val(json.file);
        }
    }
}

//删除图片
function remove_pic(mbj){
    var pathImg=mbj.val();
    if(pathImg){
        $.ajax({
            type:'post',
            url:"{:U('Setting/remove_pic')}",
            data:{imgPath:pathImg},
            success:function(){ }
        });
    }
    mbj.val('');
}
</script>